package com.fsxgt.datagrid.component.controller;

import java.io.IOException;
import java.sql.SQLException;
import java.util.concurrent.ExecutionException;

import org.apache.ibatis.executor.ExecutorException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.fsxgt.datagrid.component.bo.CmpFetchOneBO;
import com.fsxgt.datagrid.component.service.impl.CmpFetchOneService;
import com.fsxgt.datagrid.core.exception.DataGridException;
import com.fsxgt.datagrid.core.utils.ReturnT;
import com.fsxgt.datagrid.ds.service.impl.DatasourceJdbcService;
import com.fsxgt.datagrid.ds.service.impl.MetaService;
import com.fsxgt.datagrid.flow.exception.FlowException;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Api(tags = "数据抓取接口", value = "FetchOneController")
@RequestMapping(produces = "application/json; charset=UTF-8",path = "/fetchOne")
@RestController
public class FetchOneController extends BaseController {

	@Autowired
	private DatasourceJdbcService datasourceJdbcService;
	@Autowired
	private CmpFetchOneService cmpFetchOneService;
	
	
	@Autowired
	private MetaService metaService;
 

	@ApiOperation(hidden = true, value = "保存", notes = "")
	@RequestMapping(path = "/saveFetchOne", method = RequestMethod.POST)
	public ReturnT saveFetchOne(@RequestBody CmpFetchOneBO bo) throws DataGridException, IOException, ExecutorException, NumberFormatException, ExecutionException, SQLException, FlowException {
		
		cmpFetchOneService.saveCmpFetchOne(bo);
		
		return new ReturnT();

	}
	
	@ApiOperation(hidden = true, value = "获取组件", notes = "")
	@RequestMapping(path = "/getFetchOne", method = RequestMethod.POST)
	public ReturnT getFetchOne(@RequestBody CmpFetchOneBO cmpFetchOneBO) throws DataGridException, IOException, ExecutorException, NumberFormatException, ExecutionException {
		
		CmpFetchOneBO bo = cmpFetchOneService.getFetchOne(cmpFetchOneBO);
		
		return new ReturnT(bo);

	}
	
	
	
	
	


	

}